<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .max-box{
            display: flex;
            height: 60px;
            line-height: 60px;
        }
        .item{
            flex: 1;
            text-align: center;
        }
    </style>
</head>
<body>
    <!-- 具名插槽 具体到哪一个插槽 插入什么内容 -->
    <div id="app">
        {{ changeInput }}
        <my-cpn>
            <span slot="left">菜单</span>
            <input type="text" v-model="inputData" slot="center">
            <span slot="right">箭头</span>
        </my-cpn>

        <my-cpn>
            <span slot="left">返回</span>
            <span slot="center">购物车</span>
            <span slot="right">...</span>
        </my-cpn>
    </div>
    <script src="../js/vue.js"></script>
    <template id="myCpn">
        <div class="max-box">
            <div class="item">
                <slot name="left"></slot>
            </div>
            <div class="item">
                <slot name="center"></slot>
            </div>
            <div class="item">
                <slot name="right"></slot>
            </div>
        </div>
    </template>
    <script>
        const app = new Vue({
            el: '#app',
            data(){
                return {
                    inputData:'',
                    changeInput:'我是原本的数据'
                }
            },
            watch:{
                inputData(newQuestion, oldQuestion){
                    this.changeInput = '我是监听到数据改变以后的数据'
                    console.log(111)
                }
            },
            components:{
                'my-cpn':{
                    template:'#myCpn',
                    data(){
                        return {
                            inputData:''
                        }
                    }
                }
            }
        })
    </script>
</body>
</html>